//---------------------------------------------------------------------------
/** バージョン情報、プラグイン情報・設定を表示するフォーム
 */
//---------------------------------------------------------------------------
/*
 * Copyright (c) 1999 - 2005 shimitei
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. The name of the author may not be used to endorse or promote products
 *    derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop

#include "aboutform.h"
#include "mainform.h"
#include "spi_manage.h"
#include "xpi_manage.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
//TAboutForm *AboutForm;
//---------------------------------------------------------------------------
__fastcall TAboutForm::TAboutForm(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TAboutForm::OKButtonClick(TObject *Sender)
{
    Close() ;
}
//---------------------------------------------------------------------------
void __fastcall TAboutForm::FormCreate(TObject *Sender)
{
/** フォームの初期化
 * アイコン、バージョン情報、プラグイン情報の設定
 */
    // アイコン
    IconImage->Picture->Assign( Application->Icon ) ;

    // バージョン情報
    VersionLabel->Caption = ABC_VER ;

    //プラグイン情報
    int spi_count = g_spiManager.getCount00AM()
                    + g_spiManager.getCount00IN() ;

    SusiePlugListBox->Items->Add( "Susieプラグイン：" + (AnsiString)spi_count + "個" ) ;
    for (int i=0; i < spi_count; i++)
    {
        SusiePlugListBox->Items->Add( g_spiManager.getSpiInfo( i, 1 ) ) ;
    }

    int xpi_count = g_xpiManager.getXpiCount() ;
    ExportPlugListBox->Items->Add( "出力プラグイン：" + (AnsiString)xpi_count + "個" ) ;
    for (int i=0; i < xpi_count; i++)
    {
        ExportPlugListBox->Items->Add( g_xpiManager.getXpiInfo( i, 1 ) ) ;
    }
}
//---------------------------------------------------------------------------
void __fastcall TAboutForm::SusiePlugListBoxDblClick(TObject *Sender)
{
/** Susieプラグインの設定ダイアログを表示する
 */
    if ( SusiePlugListBox->ItemIndex == 0 ) return ;

    g_spiManager.spiConfig( SusiePlugListBox->ItemIndex -1, Handle, 1 ) ;
}
//---------------------------------------------------------------------------
void __fastcall TAboutForm::ExportPlugListBoxDblClick(TObject *Sender)
{
/** 出力プラグインの設定ダイアログを表示する
 */
    if ( ExportPlugListBox->ItemIndex == 0 ) return ;

    g_xpiManager.xpiConfig( ExportPlugListBox->ItemIndex -1, Handle, 1 ) ;
}
//---------------------------------------------------------------------------
void __fastcall TAboutForm::SusiePlugListBoxClick(TObject *Sender)
{
/** 表示しきれない場合のためにクリックでヒントを出す
 */
    TListBox *listBox = (TListBox *)Sender ;
    listBox->ShowHint = true ;
    listBox->Hint = listBox->Items->Strings[listBox->ItemIndex] ;
}
//---------------------------------------------------------------------------

